package cn.gson.springboot.model.pojos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Date;
import java.util.Collection;
import java.util.Objects;

@Entity
@Table(name = "return_", schema = "crm")
public class Return {
    private int returnId;
    private String returnTheme;
    private String returnNo;
    private Date returnDate;
    private BigDecimal returnRefund;
    private BigDecimal returnRefunded;
    private Integer returnStatus;
    private String returnCustomerName;
    private String returnEmpName;
    private String returnContactName;
    private Contract contractByContractId;
    private Collection<Returnlist> returnlistsByReturnId;

    @Id
    @Column(name = "return_id", nullable = false)
    public int getReturnId() {
        return returnId;
    }

    public void setReturnId(int returnId) {
        this.returnId = returnId;
    }


    @Basic
    @Column(name = "return_theme", nullable = true, length = 255)
    public String getReturnTheme() {
        return returnTheme;
    }

    public void setReturnTheme(String returnTheme) {
        this.returnTheme = returnTheme;
    }

    @Basic
    @Column(name = "return_no", nullable = true, length = 255)
    public String getReturnNo() {
        return returnNo;
    }

    public void setReturnNo(String returnNo) {
        this.returnNo = returnNo;
    }

    @Basic
    @Column(name = "return_date", nullable = true)
    public Date getReturnDate() {
        return returnDate;
    }

    public void setReturnDate(Date returnDate) {
        this.returnDate = returnDate;
    }

    @Basic
    @Column(name = "return_refund", nullable = true, precision = 2)
    public BigDecimal getReturnRefund() {
        return returnRefund;
    }

    public void setReturnRefund(BigDecimal returnRefund) {
        this.returnRefund = returnRefund;
    }

    @Basic
    @Column(name = "return_refunded", nullable = true, precision = 2)
    public BigDecimal getReturnRefunded() {
        return returnRefunded;
    }

    public void setReturnRefunded(BigDecimal returnRefunded) {
        this.returnRefunded = returnRefunded;
    }

    @Basic
    @Column(name = "return_status", nullable = true)
    public Integer getReturnStatus() {
        return returnStatus;
    }

    public void setReturnStatus(Integer returnStatus) {
        this.returnStatus = returnStatus;
    }

    @Basic
    @Column(name = "return_customer_name", nullable = true, length = 255)
    public String getReturnCustomerName() {
        return returnCustomerName;
    }

    public void setReturnCustomerName(String returnCustomerName) {
        this.returnCustomerName = returnCustomerName;
    }

    @Basic
    @Column(name = "return_emp_name", nullable = true, length = 255)
    public String getReturnEmpName() {
        return returnEmpName;
    }

    public void setReturnEmpName(String returnEmpName) {
        this.returnEmpName = returnEmpName;
    }

    @Basic
    @Column(name = "return_contact_name", nullable = true, length = 255)
    public String getReturnContactName() {
        return returnContactName;
    }

    public void setReturnContactName(String returnContactName) {
        this.returnContactName = returnContactName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Return aReturn = (Return) o;
        return returnId == aReturn.returnId &&
                Objects.equals(returnTheme, aReturn.returnTheme) &&
                Objects.equals(returnNo, aReturn.returnNo) &&
                Objects.equals(returnDate, aReturn.returnDate) &&
                Objects.equals(returnRefund, aReturn.returnRefund) &&
                Objects.equals(returnRefunded, aReturn.returnRefunded) &&
                Objects.equals(returnStatus, aReturn.returnStatus) &&
                Objects.equals(returnCustomerName, aReturn.returnCustomerName) &&
                Objects.equals(returnEmpName, aReturn.returnEmpName) &&
                Objects.equals(returnContactName, aReturn.returnContactName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(returnId,returnTheme, returnNo, returnDate, returnRefund, returnRefunded, returnStatus, returnCustomerName, returnEmpName, returnContactName);
    }

    @ManyToOne
    @JoinColumn(name = "contract_id", referencedColumnName = "contract_id")
    public Contract getContractByContractId() {
        return contractByContractId;
    }

    public void setContractByContractId(Contract contractByContractId) {
        this.contractByContractId = contractByContractId;
    }

    @OneToMany(mappedBy = "returnByReturnId")
    public Collection<Returnlist> getReturnlistsByReturnId() {
        return returnlistsByReturnId;
    }

    public void setReturnlistsByReturnId(Collection<Returnlist> returnlistsByReturnId) {
        this.returnlistsByReturnId = returnlistsByReturnId;
    }
}
